const btn = document.querySelector(".sub");
const add1 = document.querySelector(".add1")
const add2 = document.querySelector(".add2")
const add3 = document.querySelector(".add3")
const add4 = document.querySelector(".add4")
const add5 = document.querySelector(".add5")
var otbody = document.getElementsByTagName("tbody")[0];
const tip1 = document.querySelector(".tip1")
const tip2 = document.querySelector(".tip2")
const tip3 = document.querySelector(".tip3")
const tip4 = document.querySelector(".tip4")
btn.onclick = function(){
    let td1 = document.createElement("td")
    let td2 = document.createElement("td")
    let td3 = document.createElement("td")
    let td4 = document.createElement("td")
    let td5 = document.createElement("td")
    let td6 = document.createElement("td")
    let tr = document.createElement("tr")

    td6.onclick = function(){
        tr.remove();
    }
    if(add1.value === ""){
        tip1.style.display = "block";
        tip2.style.display = "none";
        tip3.style.display = "none";
        tip4.style.display = "none";
    }else if(add2.value === ""){
        tip1.style.display = "none";
        tip2.style.display = "block";
        tip3.style.display = "none";
        tip4.style.display = "none";
    }else if(add4.value === ""){
        tip1.style.display = "none";
        tip2.style.display = "none";
        tip3.style.display = "block";
        tip4.style.display = "none";
    }else if(add5.value === ""){
        tip1.style.display = "none";
        tip2.style.display = "none";
        tip3.style.display = "none";
        tip4.style.display = "block";
    }else{
        tip4.style.display = "none";

        td1.innerHTML = add1.value;
        td2.innerHTML = add2.value;
        td3.innerHTML = add3.value;
        td4.innerHTML = add4.value;
        td5.innerHTML = add5.value;
        console.log(td1.innerHTML)
        td6.innerHTML = "删除";
        td6.style.cursor = "pointer";
        add1.value = add2.value = add3.value = add4.value = add5.value = "";
        console.log(td1.innerHTML)
        otbody.appendChild(tr);
        tr.appendChild(td1);
        tr.appendChild(td2);
        tr.appendChild(td3);
        tr.appendChild(td4);
        tr.appendChild(td5);
        tr.appendChild(td6);
    }
}

